package com.xiu.java8.lambda;
//lambda 实现 Runnable 接口
public class LambdaTtest2 {

	public static void main(String[] args) {
		MathOperation2 addition=(x,y)->x-y;
		System.out.println(addition.operation(10, 5));
		// 1.1使用匿名内部类  
		new Thread(new Runnable() {  
		    @Override  
		    public void run() {  
		        System.out.println("Hello world !");  
		    }  
		}).start();  
		// 1.2使用 lambda expression
		new Thread(()->System.out.println("Hello world !")).start();
		// 2.1使用匿名内部类  
		Runnable race1 = new Runnable() {  
		    @Override  
		    public void run() {  
		        System.out.println("Runnable race1");  
		    }  
		};  
		Runnable race2=()->System.out.println("Runnable race2");
		race1.run();
		race2.run();
	}

}
interface MathOperation2 {
    int operation(int a, int b);
    default int addition(int a, int b){
        return a+b;
    }
}